package cn.linran._03_oneway;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;

import java.nio.charset.StandardCharsets;

public class OneWayProducer {
    public static void main(String[] args) throws Exception {
        //1.1创建生产者对象
        DefaultMQProducer producer = new DefaultMQProducer("OneWay_group");
        //1.2连接NameServer
        producer.setNamesrvAddr("localhost:9876");
        //1.3启动生产者
        producer.start();
        //1.4创建消息
        Message message = new Message("OneWay_topic", "OneWay_tags", "今天学java".getBytes(StandardCharsets.UTF_8));
        //1.5发送同步消息
        producer.sendOneway(message);
    }
}
